package com.xintool.window.Buttons;

import javax.swing.*;
import java.awt.*;
//置顶按钮废弃，更新为非省略即置顶
@Deprecated
public class Button_top {
    private final JFrame parentFrame;

    public Button_top(JFrame parentFrame) {
        this.parentFrame = parentFrame;
    }

    public JToggleButton showButton() {
        // 利用按钮工厂创建按钮实例
        JToggleButton button_top = new JToggleButton("置顶");//按钮显示文本为“置顶”
        //设置字体和大小
        button_top.setFont(new Font("微软雅黑", Font.PLAIN, 12));
        //设置按钮大小
        button_top.setPreferredSize(new Dimension(90,27));
        button_top.setFocusPainted(false); // 取消焦点边框
        //添加点击事件监听
        button_top.addActionListener(e -> {
            parentFrame.setAlwaysOnTop(button_top.isSelected());
        });
        return button_top;
    }
}
